#pragma once

#include <CGalaxy.h>
#ifndef STRIP
#include <CMPI.h>
#endif
#include <CRenderingParams.h>

class CRasterizer {
 public:
  
  vector<CGalaxy*> galaxies;
  vector<CGraph*> spectra;

  CRenderingParams RP;

#ifndef STRIP
  CMPI* mpi;
  void Slave();
  void Master();
  void Render();
#endif

  C2DImage image;
  C2DImage lensplane;

  void AllocateData();
  void Prepare();
  void RenderPart(bool isMaster);
  void setupCamera(int idx);

  void setupLensPlane();


  void renderPixel(int idx);
  double renderAxis(CVector isp1, CVector isp2, CVector ispDisk);

  void setupLensing(int idx);
  
  
  CGalaxy* AddGalaxy(string file, CVector position, CVector orientation, double iscale);


  double getZfromFWHM(CVector galpos, double FWHM);
  void LoadRenderlist(string fname);

  //  void createBMP(string filename, C2DImage& disk, C2DImage& arm, CVector c1, CVector c2);


  void loadSpectra();

  double getIntensity(CGalaxy* g, double& I, CVector& isp1, CVector& isp2);


};
